import { ObjCreate } from "../common/ObjCreate";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { ESignStatus } from "../../../../Message/Public/ESignStatus";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class HolidaySignRenderGetBtn
    
    export  class HolidaySignRenderGetBtn /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initView();
            return;
        }

        public get state(): int
        {
            return this._state;
        }

        /* internal  */initView(): void
        {
            this._getBtn = ObjCreate.createGButton("", 0, 0, 80, 25, this, "HolidaySignBtn");
            this._btnStateBm = ObjCreate.createBitmap("", 17, 2, this);
            LoaderHelp.addResCallBack(ResFileConst.holidaySign, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._load = true;
            this.updateStateBm(this._state);
            return;
        }

        /* internal  */updateStateBm(arg1: int): void
        {
            if (arg1 == -1) 
            {
                return;
            }
            this._btnStateBm.x = 17;
            if (!(this._lightMask == null) && this._lightMask.parent is HolidaySignRenderGetBtn) 
            {
                this.disposeLightMask();
            }
            if (arg1 != ESignStatus._ESignUnavailable) 
            {
                if (arg1 != ESignStatus._ESignSupplement) 
                {
                    if (arg1 != ESignStatus._ESignFree) 
                    {
                        if (arg1 == ESignStatus._ESignDone) 
                        {
                            this._getBtn.enabled = false;
                            this.mouseEnabled = false;
                            this._btnStateBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.holidaySignSigned);
                        }
                    }
                    else 
                    {
                        this._getBtn.enabled = true;
                        this.mouseEnabled = true;
                        this.addLightMask();
                        this._btnStateBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.holidaySignSign);
                    }
                }
                else 
                {
                    this._getBtn.enabled = true;
                    this.mouseEnabled = true;
                    this._btnStateBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.holidaySignBuqian);
                }
            }
            else 
            {
                this._getBtn.enabled = false;
                this.mouseEnabled = false;
                this._btnStateBm.x = 10;
                this._btnStateBm.bitmapData = GlobalClass.getBitmapData(ImagesConst.holidaySignStart);
            }
            return;
        }

        public disposeLightMask(): void
        {
            if (this._lightMask) 
            {
                if (this._lightMask.parent) 
                {
                    this._lightMask.parent.removeChild(this._lightMask);
                }
                this._lightMask.x = 0;
                this._lightMask.y = 0;
                this._lightMask.transform.matrix = new Object /* flash.geom.Matrix */();
                this._lightMask.stop();
                ObjectPool.disposeObject(this._lightMask);
                this._lightMask = null;
            }
            return;
        }

        /* internal  */addLightMask(): void
        {
            if (this._lightMask == null) 
            {
                this._lightMask = ObjectPool.getObject(LightMask);
                this._lightMask.transform.matrix = new Object /* flash.geom.Matrix */();
            }
            if (!this._lightMask.parent || !(this._lightMask.parent == this)) 
            {
                this._lightMask.gotoAndStop(1);
                this._lightMask.x = -1;
                this._lightMask.y = -1;
                this._lightMask.scaleX = 2.3;
                this._lightMask.scaleY = 0.72;
                this._lightMask.play();
                addChild(this._lightMask);
            }
            return;
        }

        public updateState(arg1: int): void
        {
            this._state = arg1;
            if (this._load) 
            {
                this.updateStateBm(this._state);
            }
            return;
        }

        /* internal */ /* var */_getBtn: GButton;

        /* internal */ /* var */_btnStateBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_load: Boolean;

        /* internal */ /* var */_state: int=-1;

        /* internal */ /* var */_lightMask: LightMask;
    }
